import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GTextFormat } from "../../../common/GTextFormat";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { LockInfoData } from "./LockInfoData";
import { ELockStatus } from "../../../../Message/Game/ELockStatus";
import { GButton } from "../../../../com/mui/controls/GButton";
//class LockIntroSprite
    
    export  class LockIntroSprite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc4=null;
            var loc1=ObjCreate.createBg(0, 3, 405, 320, this);
            var loc2=Language.getString(35505);
            var loc3=ObjCreate.createTextField("", 10, 10, 385, 220, this);
            loc3.defaultTextFormat = new GTextFormat("", 12, 11661311, null, null, null, null, null, null, null, null, null, 5);
            loc3.wordWrap = true;
            loc3.multiline = true;
            loc3.htmlText = loc2;
            loc3.filters = [];
            loc4 = Language.getString(35506);
            var loc5;
            (loc5 = ObjCreate.createTextField("", 10, 215, 385, 80, this)).defaultTextFormat = new GTextFormat("", 12, 65280, null, null, null, null, null, null, null, null, null, 5);
            loc5.wordWrap = true;
            loc5.multiline = true;
            loc5.htmlText = loc4;
            loc5.filters = [];
            this._setPassWordBtn = ObjCreate.createGButton(Language.getString(35507), 50, 290, 70, 25, this);
            this._setPassWordBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSetPassWordBtnHandler);
            this._cancelProtectBtn = ObjCreate.createGButton(Language.getString(35500), 50, 290, 70, 25, this);
            this._cancelProtectBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onCancelProtectBtnHandler);
            this._setUnLockBtn = ObjCreate.createGButton(Language.getString(35508), 130, 290, 70, 25, this);
            this._setUnLockBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSetUnLockBtnHandler);
            this._modifyPwBtn = ObjCreate.createGButton(Language.getString(35509), 210, 290, 70, 25, this);
            this._modifyPwBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onModifyPwBtnHandler);
            this._findPwBtn = ObjCreate.createGButton(Language.getString(35510), 290, 290, 70, 25, this);
            this._findPwBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onFindPwBtnHandler);
            return;
        }

        /* internal  */onSetPassWordBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LockSetPassWordOpen));
            return;
        }

        /* internal  */onCancelProtectBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LockCancelProtectOpen));
            return;
        }

        /* internal  */onSetUnLockBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LockSetUnLockOpen));
            return;
        }

        /* internal  */onModifyPwBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LockModifyPassWordOpen));
            return;
        }

        /* internal  */onFindPwBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LockFindPassWordOpen));
            return;
        }

        public updateInfo(): void
        {
            var loc1=LockInfoData.lockStatus;
            if (loc1.value() == ELockStatus._ELockStatusLocked || loc1.value() == ELockStatus._ELockStatusUnLocked) 
            {
                this._setPassWordBtn.visible = false;
                this._cancelProtectBtn.visible = true;
                this._setUnLockBtn.enabled = true;
                this._modifyPwBtn.enabled = true;
                this._findPwBtn.enabled = true;
            }
            else if (loc1.value() == ELockStatus._ELockStatusNoPassword || loc1.value() == ELockStatus._ELockStatusNULL) 
            {
                this._setPassWordBtn.visible = true;
                this._cancelProtectBtn.visible = false;
                this._setUnLockBtn.enabled = false;
                this._modifyPwBtn.enabled = false;
                this._findPwBtn.enabled = false;
            }
            return;
        }

        /* internal */ /* var */_setPassWordBtn: GButton;

        /* internal */ /* var */_cancelProtectBtn: GButton;

        /* internal */ /* var */_setUnLockBtn: GButton;

        /* internal */ /* var */_modifyPwBtn: GButton;

        /* internal */ /* var */_findPwBtn: GButton;
    }
